#include "AAngle_Inter.h" 
//
//
//
//
void AComb_Angle_Inter::Assign_Variables(CDraw &para, AVariable &var){
	if (angle_switch["out1_out1"]){
		for(int iter_angle=0; iter_angle < out1_out1_size(); iter_angle++){
			var.Assign_Variables(out1_out1_angle[iter_angle]);
		}
	}
	if (angle_switch["out1_out2"]){
		for(int iter_angle=0; iter_angle < out1_out2_size(); iter_angle++){
			var.Assign_Variables(out1_out2_angle[iter_angle]);
		}
	}
	if (angle_switch["out1_comb"]){
		for(int iter_angle=0; iter_angle < out1_comb_size(); iter_angle++){
			var.Assign_Variables(out1_comb_angle[iter_angle]);
		}
	}
	if (angle_switch["out1_left1"]){
		for(int iter_angle=0; iter_angle < out1_left1_size(); iter_angle++){
			var.Assign_Variables(out1_left1_angle[iter_angle]);
		}
	}
	if (angle_switch["out1_left2"]){
		for(int iter_angle=0; iter_angle < out1_left2_size(); iter_angle++){
			var.Assign_Variables(out1_left2_angle[iter_angle]);
		}
	}
	if (angle_switch["out2_out1"]){
		for(int iter_angle=0; iter_angle < out2_out1_size(); iter_angle++){
			var.Assign_Variables(out2_out1_angle[iter_angle]);
		}
	}
	if (angle_switch["out2_out2"]){
		for(int iter_angle=0; iter_angle < out2_out2_size(); iter_angle++){
			var.Assign_Variables(out2_out2_angle[iter_angle]);
		}
	}
	if (angle_switch["out2_comb"]){
		for(int iter_angle=0; iter_angle < out2_comb_size(); iter_angle++){
			var.Assign_Variables(out2_comb_angle[iter_angle]);
		}
	}
	if (angle_switch["out2_left1"]){
		for(int iter_angle=0; iter_angle < out2_left1_size(); iter_angle++){
			var.Assign_Variables(out2_left1_angle[iter_angle]);
		}
	}
	if (angle_switch["out2_left2"]){
		for(int iter_angle=0; iter_angle < out2_left2_size(); iter_angle++){
			var.Assign_Variables(out2_left2_angle[iter_angle]);
		}
	}
	if (angle_switch["left1_out1"]){
		for(int iter_angle=0; iter_angle < left1_out1(); iter_angle++){
			var.Assign_Variables(left1_out1_angle[iter_angle]);
		}
	}
	if (angle_switch["left1_out2"]){
		for(int iter_angle=0; iter_angle < left1_out2(); iter_angle++){
			var.Assign_Variables(left1_out2_angle[iter_angle]);
		}
	}
	if (angle_switch["left1_comb"]){
		for(int iter_angle=0; iter_angle < left1_comb_size(); iter_angle++){
			var.Assign_Variables(left1_comb_angle[iter_angle]);
		}
	}
	if (angle_switch["left1_left1"]){
		for(int iter_angle=0; iter_angle < left1_left1_size(); iter_angle++){
			var.Assign_Variables(left1_left1_angle[iter_angle]);
		}
	}
	if (angle_switch["left1_left2"]){
		for(int iter_angle=0; iter_angle < left1_left2_size(); iter_angle++){
			var.Assign_Variables(left1_left2_angle[iter_angle]);
		}
	}
	if (angle_switch["left2_out1"]){
		for(int iter_angle=0; iter_angle < left2_out1(); iter_angle++){
			var.Assign_Variables(left2_out1_angle[iter_angle]);
		}
	}
	if (angle_switch["left2_out2"]){
		for(int iter_angle=0; iter_angle < left2_out2(); iter_angle++){
			var.Assign_Variables(left2_out2_angle[iter_angle]);
		}
	}
	if (angle_switch["left2_comb"]){
		for(int iter_angle=0; iter_angle < left2_comb_size(); iter_angle++){
			var.Assign_Variables(left2_comb_angle[iter_angle]);
		}
	}
	if (angle_switch["left2_left1"]){
		for(int iter_angle=0; iter_angle < left2_left1_size(); iter_angle++){
			var.Assign_Variables(left2_left1_angle[iter_angle]);
		}
	}
	if (angle_switch["left2_left2"]){
		for(int iter_angle=0; iter_angle < left2_left2_size(); iter_angle++){
			var.Assign_Variables(left2_left2_angle[iter_angle]);
		}
	}
}


void AComb_Angle_Inter::Set_Variables(AComb_LTV &input1, AComb_LTV &input2){
	_A = input1;
	_B = input2;
	_title = "Angle for "+input1.Title() + " + " + input2.Title();
	_has_LTV = true;
}



void AComb_Angle_Inter::Set_Angle(){
	//	ShowMessage(2,"in Comb Angle Inter begin", _title, _has_LTV);
	if(!_has_LTV){
		ShowMessage(2,"not set Variables");
		return;
	}
	//out1 
	//ShowMessage(2,"in Angle_Inter", _A.out.out1.size(), _B.out.out1.size());
	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			//ShowMessage(2,"in Angle_Inter con", i, j, _A.out.out1[i], _B.out.out1[j]);
			out1_out1_angle.push_back(_A.out.out1[i].Angle(_B.out.out1[j].Vect() ));
			_num_out1_out1++ ;
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out1_out2_angle.push_back(_A.out.out1[i].Angle(_B.out.out2[j].Vect() ));
			_num_out1_out2++ ;
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		out1_comb_angle.push_back(_A.out.out1[i].Angle(_B.out.comb.Vect() ));
		_num_out1_comb++ ;
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out1_left1_angle.push_back(_A.out.out1[i].Angle(_B.out.left1[j].Vect() ));
			_num_out1_left1++ ;
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out1_left2_angle.push_back(_A.out.out1[i].Angle(_B.out.left2[j].Vect() ));
			_num_out1_left2++ ;
		}
	}

	//out2
	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			out2_out1_angle.push_back(_A.out.out2[i].Angle(_B.out.out1[j].Vect() ));
			_num_out2_out1++ ;
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out2_out2_angle.push_back(_A.out.out2[i].Angle(_B.out.out2[j].Vect() ));
			_num_out2_out2++ ;
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		out2_comb_angle.push_back(_A.out.out2[i].Angle(_B.out.comb.Vect() ));
		_num_out2_comb++ ;
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out2_left1_angle.push_back(_A.out.out2[i].Angle(_B.out.left1[j].Vect() ));
			_num_out2_left1++ ;
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out2_left2_angle.push_back(_A.out.out2[i].Angle(_B.out.left2[j].Vect() ));
			_num_out2_left2++ ;
		}
	}


	//comb
	for(int j=0; j < _B.out.out1.size(); j++){
		comb_out1_angle.push_back(_A.out.comb.Angle(_B.out.out1[j].Vect() ));
		_num_comb_out1++ ;
	}

	for(int j=0; j < _B.out.out2.size(); j++){
		comb_out2_angle.push_back(_A.out.comb.Angle(_B.out.out2[j].Vect() ));
		_num_comb_out2++ ;
	}

	comb_comb_angle.push_back(_A.out.comb.Angle(_B.out.comb.Vect()));
	_num_comb_comb++ ;

	for(int j=0; j < _B.out.left1.size(); j++){
		comb_left1_angle.push_back(_A.out.comb.Angle(_B.out.left1[j].Vect() ));
		_num_comb_left1++ ;
	}

	for(int j=0; j < _B.out.left2.size(); j++){
		comb_left2_angle.push_back(_A.out.comb.Angle(_B.out.left2[j].Vect() ));
		_num_comb_left2++ ;
	}


	//left1
	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left1_out1_angle.push_back(_A.out.left1[i].Angle(_B.out.out1[j].Vect() ));
			_num_left1_out1++ ;
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left1_out2_angle.push_back(_A.out.left1[i].Angle(_B.out.out2[j].Vect() ));
			_num_left1_out2++ ;
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		left1_comb_angle.push_back(_A.out.left1[i].Angle(_B.out.comb.Vect() ));
		_num_left1_comb++ ;
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left1_left1_angle.push_back(_A.out.left1[i].Angle(_B.out.left1[j].Vect() ));
			_num_left1_left1++ ;
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left1_left2_angle.push_back(_A.out.left1[i].Angle(_B.out.left2[j].Vect() ));
			_num_left1_left2++ ;
		}
	}



	//left2
	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left2_out1_angle.push_back(_A.out.left2[i].Angle(_B.out.out1[j].Vect() ));
			_num_left2_out1++ ;
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left2_out2_angle.push_back(_A.out.left2[i].Angle(_B.out.out2[j].Vect() ));
			_num_left2_out2++ ;
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		left2_comb_angle.push_back(_A.out.left2[i].Angle(_B.out.comb.Vect() ));
		_num_left2_comb++ ;
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left2_left1_angle.push_back(_A.out.left2[i].Angle(_B.out.left1[j].Vect() ));
			_num_left2_left1++ ;
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left2_left2_angle.push_back(_A.out.left2[i].Angle(_B.out.left2[j].Vect() ));
			_num_left2_left2++ ;
		}
	}
	_num = _num + _num_out1_out1 + _num_out1_out2 + _num_out1_comb + _num_out1_left1 + _num_out1_left2;
	_num = _num + _num_out2_out1 + _num_out2_out2 + _num_out2_comb + _num_out2_left1 + _num_out2_left2;
	_num = _num + _num_comb_out1 + _num_comb_out2 + _num_comb_comb + _num_comb_left1 + _num_comb_left2;
	_num = _num + _num_left1_out1 + _num_left1_out2 + _num_left1_comb + _num_left1_left1 + _num_left1_left2;
	_num = _num + _num_left2_out1 + _num_left2_out2 + _num_left2_comb + _num_left2_left1 + _num_left2_left2;

}

int AComb_Angle_Inter::Num(std::string name){
	if(name == ""){
		return(_num);
	}
	else if(name == "out1_out1"){
		return(_num_out1_out1);
	}
	else if(name == "out1_out2"){
		return(_num_out1_out2);
	}
	else if(name == "out1_comb"){
		return(_num_out1_comb);
	}
	else if(name == "out1_left1"){
		return(_num_out1_left1);
	}
	else if(name == "out1_left2"){
		return(_num_out1_left2);
	}

	else if(name == "out2_out1"){
		return(_num_out2_out1);
	}
	else if(name == "out2_out2"){
		return(_num_out2_out2);
	}
	else if(name == "out2_comb"){
		return(_num_out2_comb);
	}
	else if(name == "out2_left1"){
		return(_num_out2_left1);
	}
	else if(name == "out2_left2"){
		return(_num_out2_left2);
	}

	else if(name == "comb_out1"){
		return(_num_comb_out1);
	}
	else if(name == "comb_out2"){
		return(_num_comb_out2);
	}
	else if(name == "comb_comb"){
		return(_num_comb_comb);
	}
	else if(name == "comb_left1"){
		return(_num_comb_left1);
	}
	else if(name == "comb_left2"){
		return(_num_comb_left2);
	}

	else if(name == "left1_out1"){
		return(_num_left1_out1);
	}
	else if(name == "left1_out2"){
		return(_num_left1_out2);
	}
	else if(name == "left1_comb"){
		return(_num_left1_comb);
	}
	else if(name == "left1_left1"){
		return(_num_left1_left1);
	}
	else if(name == "left1_left2"){
		return(_num_left1_left2);
	}

	else if(name == "left2_out1"){
		return(_num_left2_out1);
	}
	else if(name == "left2_out2"){
		return(_num_left2_out2);
	}
	else if(name == "left2_comb"){
		return(_num_left2_comb);
	}
	else if(name == "left2_left1"){
		return(_num_left2_left1);
	}
	else if(name == "left2_left2"){
		return(_num_left2_left2);
	}
	return(0);

}


void AComb_Angle_Inter::Print(int level, std::string str){

	if(str!=""){
		ShowMessage(level,"AComb_Angle_Inter contents for ", str);
	}
	else{
		ShowMessage(level,"AComb_Angle_Inter contents for ", _title);
	}
	ShowMessage(level+1,"out1_out1_angle", out1_out1_angle);
	ShowMessage(level+1,"out1_out2_angle", out2_out2_angle);
	ShowMessage(level+1,"out1_comb_angle", out1_comb_angle);
	ShowMessage(level+1,"out1_left1_angle", out1_left1_angle);
	ShowMessage(level+1,"out1_left2_angle", out1_left2_angle);

	ShowMessage(level+1,"out2_out1_angle",  out2_out1_angle);
	ShowMessage(level+1,"out2_out2_angle",  out2_out2_angle);
	ShowMessage(level+1,"out2_comb_angle",  out2_comb_angle);
	ShowMessage(level+1,"out2_left1_angle", out2_left1_angle);
	ShowMessage(level+1,"out2_left2_angle", out2_left2_angle);


	ShowMessage(level+1,"comb_out1_angle",  comb_out1_angle);
	ShowMessage(level+1,"comb_out2_angle",  comb_out2_angle);
	ShowMessage(level+1,"comb_comb_angle",  comb_comb_angle);
	ShowMessage(level+1,"comb_left1_angle", comb_left1_angle);
	ShowMessage(level+1,"comb_left2_angle", comb_left2_angle);

	ShowMessage(level+1,"left1_out1_angle",  left1_out1_angle);
	ShowMessage(level+1,"left1_out2_angle",  left1_out2_angle);
	ShowMessage(level+1,"left1_comb_angle",  left1_comb_angle);
	ShowMessage(level+1,"left1_left1_angle", left1_left1_angle);
	ShowMessage(level+1,"left1_left2_angle", left1_left2_angle);

	ShowMessage(level+1,"left2_out1_angle",  left2_out1_angle);
	ShowMessage(level+1,"left2_out2_angle",  left2_out2_angle);
	ShowMessage(level+1,"left2_comb_angle",  left2_comb_angle);
	ShowMessage(level+1,"left2_left1_angle", left2_left1_angle);
	ShowMessage(level+1,"left2_left2_angle", left2_left2_angle);
}



















void AComb_DeltaR_Inter::Set_Variables(AComb_LTV &input1, AComb_LTV &input2){
	_A = input1;
	_B = input2;
	_title = "DeltaR for "+input1.Title() + " + " + input2.Title();
	_has_LTV = true;
}

void AComb_DeltaR_Inter::Set_DeltaR(){
	if(!_has_LTV){
		ShowMessage(2,"not set Variables");
		return;
	}

	//out1 
	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			out1_out1_DeltaR.push_back(_A.out.out1[i].DeltaR(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out1_out2_DeltaR.push_back(_A.out.out1[i].DeltaR(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		out1_comb_DeltaR.push_back(_A.out.out1[i].DeltaR(_B.out.comb ));
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out1_left1_DeltaR.push_back(_A.out.out1[i].DeltaR(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out1_left2_DeltaR.push_back(_A.out.out1[i].DeltaR(_B.out.left2[j] ));
		}
	}

	//out2
	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			out2_out1_DeltaR.push_back(_A.out.out2[i].DeltaR(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out2_out2_DeltaR.push_back(_A.out.out2[i].DeltaR(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		out2_comb_DeltaR.push_back(_A.out.out2[i].DeltaR(_B.out.comb ));
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out2_left1_DeltaR.push_back(_A.out.out2[i].DeltaR(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out2_left2_DeltaR.push_back(_A.out.out2[i].DeltaR(_B.out.left2[j] ));
		}
	}


	//comb
	for(int j=0; j < _B.out.out1.size(); j++){
		comb_out1_DeltaR.push_back(_A.out.comb.DeltaR(_B.out.out1[j] ));
	}

	for(int j=0; j < _B.out.out2.size(); j++){
		comb_out2_DeltaR.push_back(_A.out.comb.DeltaR(_B.out.out2[j] ));
	}

	comb_comb_DeltaR.push_back(_A.out.comb.DeltaR(_B.out.comb));

	for(int j=0; j < _B.out.left1.size(); j++){
		comb_left1_DeltaR.push_back(_A.out.comb.DeltaR(_B.out.left1[j] ));
	}

	for(int j=0; j < _B.out.left2.size(); j++){
		comb_left2_DeltaR.push_back(_A.out.comb.DeltaR(_B.out.left2[j] ));
	}


	//left1
	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left1_out1_DeltaR.push_back(_A.out.left1[i].DeltaR(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left1_out2_DeltaR.push_back(_A.out.left1[i].DeltaR(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		left1_comb_DeltaR.push_back(_A.out.left1[i].DeltaR(_B.out.comb ));
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left1_left1_DeltaR.push_back(_A.out.left1[i].DeltaR(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left1_left2_DeltaR.push_back(_A.out.left1[i].DeltaR(_B.out.left2[j] ));
		}
	}



	//left2
	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left2_out1_DeltaR.push_back(_A.out.left2[i].DeltaR(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left2_out2_DeltaR.push_back(_A.out.left2[i].DeltaR(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		left2_comb_DeltaR.push_back(_A.out.left2[i].DeltaR(_B.out.comb ));
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left2_left1_DeltaR.push_back(_A.out.left2[i].DeltaR(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left2_left2_DeltaR.push_back(_A.out.left2[i].DeltaR(_B.out.left2[j] ));
		}
	}

}



void AComb_DeltaR_Inter::Print(int level, std::string str){
	if(str!=""){
		ShowMessage(level,"AComb_DeltaR_Inter contents for ", str);
	}
	else{
		ShowMessage(level,"AComb_DeltaR_Inter contents for ", _title);
	}
	ShowMessage(level+1,"out1_out1_DeltaR", out1_out1_DeltaR);
	ShowMessage(level+1,"out1_out2_DeltaR", out2_out2_DeltaR);
	ShowMessage(level+1,"out1_comb_DeltaR", out1_comb_DeltaR);
	ShowMessage(level+1,"out1_left1_DeltaR", out1_left1_DeltaR);
	ShowMessage(level+1,"out1_left2_DeltaR", out1_left2_DeltaR);

	ShowMessage(level+1,"out2_out1_DeltaR",  out2_out1_DeltaR);
	ShowMessage(level+1,"out2_out2_DeltaR",  out2_out2_DeltaR);
	ShowMessage(level+1,"out2_comb_DeltaR",  out2_comb_DeltaR);
	ShowMessage(level+1,"out2_left1_DeltaR", out2_left1_DeltaR);
	ShowMessage(level+1,"out2_left2_DeltaR", out2_left2_DeltaR);


	ShowMessage(level+1,"comb_out1_DeltaR",  comb_out1_DeltaR);
	ShowMessage(level+1,"comb_out2_DeltaR",  comb_out2_DeltaR);
	ShowMessage(level+1,"comb_comb_DeltaR",  comb_comb_DeltaR);
	ShowMessage(level+1,"comb_left1_DeltaR", comb_left1_DeltaR);
	ShowMessage(level+1,"comb_left2_DeltaR", comb_left2_DeltaR);

	ShowMessage(level+1,"left1_out1_DeltaR",  left1_out1_DeltaR);
	ShowMessage(level+1,"left1_out2_DeltaR",  left1_out2_DeltaR);
	ShowMessage(level+1,"left1_comb_DeltaR",  left1_comb_DeltaR);
	ShowMessage(level+1,"left1_left1_DeltaR", left1_left1_DeltaR);
	ShowMessage(level+1,"left1_left2_DeltaR", left1_left2_DeltaR);

	ShowMessage(level+1,"left2_out1_DeltaR",  left2_out1_DeltaR);
	ShowMessage(level+1,"left2_out2_DeltaR",  left2_out2_DeltaR);
	ShowMessage(level+1,"left2_comb_DeltaR",  left2_comb_DeltaR);
	ShowMessage(level+1,"left2_left1_DeltaR", left2_left1_DeltaR);
	ShowMessage(level+1,"left2_left2_DeltaR", left2_left2_DeltaR);
}


















void AComb_DeltaPhi_Inter::Set_Variables(AComb_LTV &input1, AComb_LTV &input2){
	_A = input1;
	_B = input2;
	_title = "DeltaPhi for "+input1.Title() + " + " + input2.Title();
	_has_LTV = true;
}

void AComb_DeltaPhi_Inter::Set_DeltaPhi(){
	if(!_has_LTV){
		ShowMessage(2,"not set Variables");
		return;
	}

	//out1 
	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			out1_out1_DeltaPhi.push_back(_A.out.out1[i].DeltaPhi(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out1_out2_DeltaPhi.push_back(_A.out.out1[i].DeltaPhi(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		out1_comb_DeltaPhi.push_back(_A.out.out1[i].DeltaPhi(_B.out.comb ));
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out1_left1_DeltaPhi.push_back(_A.out.out1[i].DeltaPhi(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.out1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out1_left2_DeltaPhi.push_back(_A.out.out1[i].DeltaPhi(_B.out.left2[j] ));
		}
	}

	//out2
	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			out2_out1_DeltaPhi.push_back(_A.out.out2[i].DeltaPhi(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			out2_out2_DeltaPhi.push_back(_A.out.out2[i].DeltaPhi(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		out2_comb_DeltaPhi.push_back(_A.out.out2[i].DeltaPhi(_B.out.comb ));
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			out2_left1_DeltaPhi.push_back(_A.out.out2[i].DeltaPhi(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.out2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			out2_left2_DeltaPhi.push_back(_A.out.out2[i].DeltaPhi(_B.out.left2[j] ));
		}
	}


	//comb
	for(int j=0; j < _B.out.out1.size(); j++){
		comb_out1_DeltaPhi.push_back(_A.out.comb.DeltaPhi(_B.out.out1[j] ));
	}

	for(int j=0; j < _B.out.out2.size(); j++){
		comb_out2_DeltaPhi.push_back(_A.out.comb.DeltaPhi(_B.out.out2[j] ));
	}

	comb_comb_DeltaPhi.push_back(_A.out.comb.DeltaPhi(_B.out.comb));

	for(int j=0; j < _B.out.left1.size(); j++){
		comb_left1_DeltaPhi.push_back(_A.out.comb.DeltaPhi(_B.out.left1[j] ));
	}

	for(int j=0; j < _B.out.left2.size(); j++){
		comb_left2_DeltaPhi.push_back(_A.out.comb.DeltaPhi(_B.out.left2[j] ));
	}


	//left1
	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left1_out1_DeltaPhi.push_back(_A.out.left1[i].DeltaPhi(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left1_out2_DeltaPhi.push_back(_A.out.left1[i].DeltaPhi(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		left1_comb_DeltaPhi.push_back(_A.out.left1[i].DeltaPhi(_B.out.comb ));
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left1_left1_DeltaPhi.push_back(_A.out.left1[i].DeltaPhi(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.left1.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left1_left2_DeltaPhi.push_back(_A.out.left1[i].DeltaPhi(_B.out.left2[j] ));
		}
	}



	//left2
	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out1.size(); j++){
			left2_out1_DeltaPhi.push_back(_A.out.left2[i].DeltaPhi(_B.out.out1[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.out2.size(); j++){
			left2_out2_DeltaPhi.push_back(_A.out.left2[i].DeltaPhi(_B.out.out2[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		left2_comb_DeltaPhi.push_back(_A.out.left2[i].DeltaPhi(_B.out.comb ));
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left1.size(); j++){
			left2_left1_DeltaPhi.push_back(_A.out.left2[i].DeltaPhi(_B.out.left1[j] ));
		}
	}

	for(int i=0; i < _A.out.left2.size(); i++){
		for(int j=0; j < _B.out.left2.size(); j++){
			left2_left2_DeltaPhi.push_back(_A.out.left2[i].DeltaPhi(_B.out.left2[j] ));
		}
	}

}



void AComb_DeltaPhi_Inter::Print(int level, std::string str){

	if(str!=""){
		ShowMessage(level,"AComb_DeltaPhi_Inter: for", str);
	}
	else{
		ShowMessage(level,"AComb_DeltaPhi_Inter: for", _title);
	}
	ShowMessage(level+1,"out1_out1_DeltaPhi", out1_out1_DeltaPhi);
	ShowMessage(level+1,"out1_out2_DeltaPhi", out2_out2_DeltaPhi);
	ShowMessage(level+1,"out1_comb_DeltaPhi", out1_comb_DeltaPhi);
	ShowMessage(level+1,"out1_left1_DeltaPhi", out1_left1_DeltaPhi);
	ShowMessage(level+1,"out1_left2_DeltaPhi", out1_left2_DeltaPhi);

	ShowMessage(level+1,"out2_out1_DeltaPhi",  out2_out1_DeltaPhi);
	ShowMessage(level+1,"out2_out2_DeltaPhi",  out2_out2_DeltaPhi);
	ShowMessage(level+1,"out2_comb_DeltaPhi",  out2_comb_DeltaPhi);
	ShowMessage(level+1,"out2_left1_DeltaPhi", out2_left1_DeltaPhi);
	ShowMessage(level+1,"out2_left2_DeltaPhi", out2_left2_DeltaPhi);


	ShowMessage(level+1,"comb_out1_DeltaPhi",  comb_out1_DeltaPhi);
	ShowMessage(level+1,"comb_out2_DeltaPhi",  comb_out2_DeltaPhi);
	ShowMessage(level+1,"comb_comb_DeltaPhi",  comb_comb_DeltaPhi);
	ShowMessage(level+1,"comb_left1_DeltaPhi", comb_left1_DeltaPhi);
	ShowMessage(level+1,"comb_left2_DeltaPhi", comb_left2_DeltaPhi);

	ShowMessage(level+1,"left1_out1_DeltaPhi",  left1_out1_DeltaPhi);
	ShowMessage(level+1,"left1_out2_DeltaPhi",  left1_out2_DeltaPhi);
	ShowMessage(level+1,"left1_comb_DeltaPhi",  left1_comb_DeltaPhi);
	ShowMessage(level+1,"left1_left1_DeltaPhi", left1_left1_DeltaPhi);
	ShowMessage(level+1,"left1_left2_DeltaPhi", left1_left2_DeltaPhi);

	ShowMessage(level+1,"left2_out1_DeltaPhi",  left2_out1_DeltaPhi);
	ShowMessage(level+1,"left2_out2_DeltaPhi",  left2_out2_DeltaPhi);
	ShowMessage(level+1,"left2_comb_DeltaPhi",  left2_comb_DeltaPhi);
	ShowMessage(level+1,"left2_left1_DeltaPhi", left2_left1_DeltaPhi);
	ShowMessage(level+1,"left2_left2_DeltaPhi", left2_left2_DeltaPhi);
}







void AComb_Inter::Set_Variables(){
	if(_has_LTV){
		angle   .Set_Variables(_A, _B);
		deltar  .Set_Variables(_A, _B);
		deltaphi.Set_Variables(_A, _B);
	}
}

void AComb_Inter::Set_Variables(AComb_LTV &input1, AComb_LTV &input2){
	_A = input1;
	_B = input2;
	_title = "Inter for "+input1.Title() + " + " + input2.Title();
	_has_LTV = true;

	angle   .Set_Variables(input1, input2);
	deltar  .Set_Variables(input1, input2);
	deltaphi.Set_Variables(input1, input2);
}


void AComb_Inter::Set_Distance(){
	//ShowMessage(2,"in Comb Inter begin");
	angle   .Set_Angle();
	deltar  .Set_DeltaR();
	deltaphi.Set_DeltaPhi();
	_num = angle.Num();
	_num_out1_out1 = angle.Num("out1_out1");  _num_out1_out2 = angle.Num("out1_out2"); _num_out1_comb = angle.Num("out1_comb"); _num_out1_left1 = angle.Num("out1_left1"); _num_out1_left2 = angle.Num("out1_left2");
	_num_out2_out1 = angle.Num("out2_out1");  _num_out2_out2 = angle.Num("out2_out2"); _num_out2_comb = angle.Num("out2_comb"); _num_out2_left1 = angle.Num("out2_left1"); _num_out2_left2 = angle.Num("out2_left2");
	_num_comb_out1 = angle.Num("comb_out1");  _num_comb_out2 = angle.Num("comb_out2"); _num_comb_comb = angle.Num("comb_comb"); _num_comb_left1 = angle.Num("comb_left1"); _num_comb_left2 = angle.Num("comb_left2");
	_num_left1_out1= angle.Num("left1_out1"); _num_left1_out2= angle.Num("left1_out2"); _num_left1_comb= angle.Num("left1_comb"); _num_left1_left1= angle.Num("left1_left1"); _num_left1_left2= angle.Num("left1_left2");
	_num_left2_out1= angle.Num("left2_out1"); _num_left2_out2= angle.Num("left2_out2"); _num_left2_comb= angle.Num("left2_comb"); _num_left2_left1= angle.Num("left2_left1"); _num_left2_left2= angle.Num("left2_left2");
	Set_Angle_Switch();
	//ShowMessage(2,"in Comb Inter end");
}

void AComb_Inter::Set_Angle_Switch(){
	if(_A.out.Kind()==1 && _B.out.Kind()==1){
		angle_switch["out1_out1"]  = true;
		angle_switch["out1_out2"]  = false;
		angle_switch["out2_out1"]  = false;
		angle_switch["out2_out2"]  = false;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = false;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = false;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==1 && _B.out.Kind()==-1){
		angle_switch["out1_out2"] = true;
		angle_switch["out1_out1"] = false;
		angle_switch["out2_out1"] = false;
		angle_switch["out2_out2"] = false;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = false;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = false;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==-1 && _B.out.Kind()==1){
		angle_switch["out1_out2"] = false;
		angle_switch["out1_out1"] = false;
		angle_switch["out2_out1"] = true;
		angle_switch["out2_out2"] = false;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = false;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = false;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==-1 && _B.out.Kind()==-1){
		angle_switch["out1_out2"] = false;
		angle_switch["out1_out1"] = false;
		angle_switch["out2_out1"] = false;
		angle_switch["out2_out2"] = true;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = false;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = false;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==2 && _B.out.Kind()==1){
		angle_switch["out1_out2"] = false;
		angle_switch["out1_out1"] = true;
		angle_switch["out2_out1"] = true;
		angle_switch["out2_out2"] = false;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = true;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = false;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==2 && _B.out.Kind()==-1){
		angle_switch["out1_out2"] = true;
		angle_switch["out1_out1"] = false;
		angle_switch["out2_out1"] = false;
		angle_switch["out2_out2"] = true;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = true;
		angle_switch["comb_out1"]  = false;
		angle_switch["comb_out2"]  = true;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==1 && _B.out.Kind()==2){
		angle_switch["out1_out2"] = true;
		angle_switch["out1_out1"] = true;
		angle_switch["out2_out1"] = false;
		angle_switch["out2_out2"] = false;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = false;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = true;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==-1 && _B.out.Kind()==2){
		angle_switch["out1_out2"] = false;
		angle_switch["out1_out1"] = true;
		angle_switch["out2_out1"] = true;
		angle_switch["out2_out2"] = false;
		angle_switch["out1_comb"]  = false;
		angle_switch["out2_comb"]  = true;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = true;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}
	else if(_A.out.Kind()==2 && _B.out.Kind()==2){
		angle_switch["out1_out2"] = true;
		angle_switch["out1_out1"] = true;
		angle_switch["out2_out1"] = true;
		angle_switch["out2_out2"] = true;
		angle_switch["out1_comb"]  = true;
		angle_switch["out2_comb"]  = true;
		angle_switch["comb_out1"]  = true;
		angle_switch["comb_out2"]  = true;
		angle_switch["comb_comb"]  = true;


		angle_switch["out2_left1"] = false;
		angle_switch["out2_left2"] = false;
		angle_switch["out1_left1"] = false;
		angle_switch["out1_left2"] = false;

		angle_switch["comb_left1"] = false;
		angle_switch["comb_left2"] = false;

		angle_switch["left1_out1"] = false;
		angle_switch["left2_out1"] = false;

		angle_switch["left1_out2"] = false;
		angle_switch["left2_out2"] = false;

		angle_switch["left1_comb"]  = false;
		angle_switch["left1_left1"] = false;
		angle_switch["left1_left2"] = false;

		angle_switch["left2_comb"]  = false;
		angle_switch["left2_left1"] = false;
		angle_switch["left2_left2"] = false;
	}

}


void AComb_Inter::Print(int level, std::string str){
	if(str!=""){
		ShowMessage(level,"AComb_Inter: for", str);
	}
	else{
		ShowMessage(level,"AComb_Inter: for", _title);
	}
	angle   .Print(level+1);
	deltar  .Print(level+1);
	deltaphi.Print(level+1);
}


int AComb_Inter::Num(std::string name){
	if(name == ""){
		return(_num);
	}
	else if(name == "out1_out1"){
		return(_num_out1_out1);
	}
	else if(name == "out1_out2"){
		return(_num_out1_out2);
	}
	else if(name == "out1_comb"){
		return(_num_out1_comb);
	}
	else if(name == "out1_left1"){
		return(_num_out1_left1);
	}
	else if(name == "out1_left2"){
		return(_num_out1_left2);
	}

	else if(name == "out2_out1"){
		return(_num_out2_out1);
	}
	else if(name == "out2_out2"){
		return(_num_out2_out2);
	}
	else if(name == "out2_comb"){
		return(_num_out2_comb);
	}
	else if(name == "out2_left1"){
		return(_num_out2_left1);
	}
	else if(name == "out2_left2"){
		return(_num_out2_left2);
	}

	else if(name == "comb_out1"){
		return(_num_comb_out1);
	}
	else if(name == "comb_out2"){
		return(_num_comb_out2);
	}
	else if(name == "comb_comb"){
		return(_num_comb_comb);
	}
	else if(name == "comb_left1"){
		return(_num_comb_left1);
	}
	else if(name == "comb_left2"){
		return(_num_comb_left2);
	}

	else if(name == "left1_out1"){
		return(_num_left1_out1);
	}
	else if(name == "left1_out2"){
		return(_num_left1_out2);
	}
	else if(name == "left1_comb"){
		return(_num_left1_comb);
	}
	else if(name == "left1_left1"){
		return(_num_left1_left1);
	}
	else if(name == "left1_left2"){
		return(_num_left1_left2);
	}

	else if(name == "left2_out1"){
		return(_num_left2_out1);
	}
	else if(name == "left2_out2"){
		return(_num_left2_out2);
	}
	else if(name == "left2_comb"){
		return(_num_left2_comb);
	}
	else if(name == "left2_left1"){
		return(_num_left2_left1);
	}
	else if(name == "left2_left2"){
		return(_num_left2_left2);
	}

	return(0);
}

